<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Function join</title>
<link rel="stylesheet" href="../../../../../../../doc/html/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../../index.html" title="Chapter&#160;1.&#160;Range 2.0">
<link rel="up" href="../utilities.html" title="Utilities">
<link rel="prev" href="sub_range.html" title="Class sub_range">
<link rel="next" href="../extending.html" title="Extending the library">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="sub_range.html"><img src="../../../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../utilities.html"><img src="../../../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="../extending.html"><img src="../../../../../../../doc/html/images/next.png" alt="Next"></a>
</div>
<div class="section" title="Function join">
<div class="titlepage"><div><div><h4 class="title">
<a name="range.reference.utilities.join"></a><a class="link" href="join.html" title="Function join"> Function join</a>
</h4></div></div></div>
<p>
          The intention of the <code class="computeroutput"><span class="identifier">join</span></code>
          function is to join two ranges into one longer range.
        </p>
<p>
          The resultant range will have the lowest common traversal of the two ranges
          supplied as parameters.
        </p>
<p>
          Note that the joined range incurs a performance cost due to the need to
          check if the end of a range has been reached internally during traversal.
        </p>
<a name="range.reference.utilities.join.synposis"></a><h5>
<a name="id666200"></a>
          <a class="link" href="join.html#range.reference.utilities.join.synposis">Synposis</a>
        </h5>
<p>

</p>
<pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">SinglePassRange1</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">SinglePassRange2</span><span class="special">&gt;</span>
<span class="identifier">iterator_range</span><span class="special">&lt;</span><span class="identifier">range_detail</span><span class="special">::</span><span class="identifier">join_iterator</span><span class="special">&lt;</span>
    <span class="keyword">typename</span> <span class="identifier">range_iterator</span><span class="special">&lt;</span><span class="keyword">const</span> <span class="identifier">SinglePassRange1</span><span class="special">&gt;::</span><span class="identifier">type</span><span class="special">,</span>
    <span class="keyword">typename</span> <span class="identifier">range_iterator</span><span class="special">&lt;</span><span class="keyword">const</span> <span class="identifier">SinglePassRange2</span><span class="special">&gt;::</span><span class="identifier">type</span><span class="special">,</span>
    <span class="keyword">typename</span> <span class="identifier">add_const</span><span class="special">&lt;</span>
        <span class="keyword">typename</span> <span class="identifier">range_value</span><span class="special">&lt;</span><span class="keyword">const</span> <span class="identifier">SinglePassRange1</span><span class="special">&gt;::</span><span class="identifier">type</span><span class="special">&gt;::</span><span class="identifier">type</span><span class="special">&gt;</span>
<span class="special">&gt;</span>
<span class="identifier">join</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">SinglePassRange1</span><span class="special">&amp;</span> <span class="identifier">rng1</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">SinglePassRange2</span><span class="special">&amp;</span> <span class="identifier">rng2</span><span class="special">)</span>

<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">SinglePassRange1</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">SinglePassRange2</span><span class="special">&gt;</span>
<span class="identifier">iterator_range</span><span class="special">&lt;</span><span class="identifier">range_detail</span><span class="special">::</span><span class="identifier">join_iterator</span><span class="special">&lt;</span>
    <span class="keyword">typename</span> <span class="identifier">range_iterator</span><span class="special">&lt;</span><span class="identifier">SinglePassRange1</span><span class="special">&gt;::</span><span class="identifier">type</span><span class="special">,</span>
    <span class="keyword">typename</span> <span class="identifier">range_iterator</span><span class="special">&lt;</span><span class="identifier">SinglePassRange2</span><span class="special">&gt;::</span><span class="identifier">type</span><span class="special">,</span>
    <span class="keyword">typename</span> <span class="identifier">range_value</span><span class="special">&lt;</span><span class="identifier">SinglePassRange1</span><span class="special">&gt;::</span><span class="identifier">type</span><span class="special">&gt;</span>
<span class="special">&gt;</span>
<span class="identifier">join</span><span class="special">(</span><span class="identifier">SinglePassRange1</span><span class="special">&amp;</span> <span class="identifier">rng1</span><span class="special">,</span> <span class="identifier">SinglePassRange2</span><span class="special">&amp;</span> <span class="identifier">rng2</span><span class="special">);</span>
</pre>
<p>
        </p>
<a name="range.reference.utilities.join.example"></a><h5>
<a name="id666734"></a>
          <a class="link" href="join.html#range.reference.utilities.join.example">Example</a>
        </h5>
<p>
          The expression <code class="computeroutput"><span class="identifier">join</span><span class="special">(</span><span class="identifier">irange</span><span class="special">(</span><span class="number">0</span><span class="special">,</span><span class="number">5</span><span class="special">),</span> <span class="identifier">irange</span><span class="special">(</span><span class="number">5</span><span class="special">,</span><span class="number">10</span><span class="special">))</span></code> would
          evaluate to a range representing an integer range <code class="computeroutput"><span class="special">[</span><span class="number">0</span><span class="special">,</span><span class="number">10</span><span class="special">)</span></code>
        </p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2003 -2010 Thorsten Ottosen, Neil Groves<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="sub_range.html"><img src="../../../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../utilities.html"><img src="../../../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="../extending.html"><img src="../../../../../../../doc/html/images/next.png" alt="Next"></a>
</div>
</body>
</html>
